This commit handles complicated cases where we selections.
We handle this by adding extend and modify parameters to
the ::move-cursor signals, and adjust the bindings
accordingly.
static void gtk_flow_box_check_model_compat (GtkFlowBox *box);
-static void
-get_current_selection_modifiers (GtkWidget *widget,
- gboolean *modify,
- gboolean *extend)
-{
- GdkModifierType state = 0;
- GdkModifierType mask;
-
- *modify = FALSE;
- *extend = FALSE;
-
- if (gtk_get_current_event_state (&state))
- {
- mask = GDK_CONTROL_MASK;
- if ((state & mask) == mask)
- *modify = TRUE;
- mask = GDK_SHIFT_MASK;
- if ((state & mask) == mask)
- *extend = TRUE;
- }
-}
-
static void
path_from_horizontal_line_rects (cairo_t *cr,
GdkRectangle *lines,
gtk_flow_box_child_set_focus (GtkFlowBoxChild *child)
{
GtkFlowBox *box = gtk_flow_box_child_get_box (child);
- gboolean modify;
- gboolean extend;
-
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
- if (modify)
- gtk_flow_box_update_cursor (box, child);
- else
- gtk_flow_box_update_selection (box, child, FALSE, FALSE);
+ gtk_flow_box_update_selection (box, child, FALSE, FALSE);
}
/* GtkWidget implementation {{{2 */
void (*toggle_cursor_child) (GtkFlowBox *box);
gboolean (*move_cursor) (GtkFlowBox *box,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
void (*select_all) (GtkFlowBox *box);
void (*unselect_all) (GtkFlowBox *box);
};
GdkEventSequence *sequence;
GdkInputSource source;
GdkEvent *event;
+ GdkModifierType state;
gboolean modify;
gboolean extend;
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
+ state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
+ modify = (state & GDK_CONTROL_MASK) != 0;
+ extend = (state & GDK_SHIFT_MASK) != 0;
/* With touch, we default to modifying the selection.
* You can still clear the selection and start over
GtkWidget *widget)
{
GtkFlowBoxPrivate *priv = BOX_PRIV (widget);
+ GdkModifierType state;
if (priv->selection_mode != GTK_SELECTION_MULTIPLE)
{
priv->rubberband_select = FALSE;
priv->rubberband_first = NULL;
priv->rubberband_last = NULL;
- get_current_selection_modifiers (widget, &priv->rubberband_modify, &priv->rubberband_extend);
+
+ state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (gesture));
+ priv->rubberband_modify = (state & GDK_CONTROL_MASK) != 0;
+ priv->rubberband_extend = (state & GDK_SHIFT_MASK) != 0;
}
static void
GtkMovementStep step,
gint count)
{
- GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
- GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
-
gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | extend_mod_mask,
+ keyval, modmask | GDK_SHIFT_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, FALSE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | modify_mod_mask,
+ keyval, modmask | GDK_CONTROL_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, TRUE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | extend_mod_mask | modify_mod_mask,
+ keyval, modmask | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, TRUE);
}
static void
static gboolean
gtk_flow_box_move_cursor (GtkFlowBox *box,
GtkMovementStep step,
- gint count)
+ gint count,
+ gboolean extend,
+ gboolean modify)
{
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
- gboolean modify;
- gboolean extend;
GtkFlowBoxChild *child;
GtkFlowBoxChild *prev;
GtkFlowBoxChild *next;
}
}
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
-
gtk_flow_box_update_cursor (box, child);
if (!modify)
gtk_flow_box_update_selection (box, child, FALSE, extend);
* @box: the #GtkFlowBox on which the signal is emitted
* @step: the granularity fo the move, as a #GtkMovementStep
* @count: the number of @step units to move
+ * @extend: whether to extend the selection
+ * @modify: whether to modify the selection
*
* The ::move-cursor signal is a
* [keybinding signal][GtkBindingSignal]
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkFlowBoxClass, move_cursor),
NULL, NULL,
- _gtk_marshal_BOOLEAN__ENUM_INT,
- G_TYPE_BOOLEAN, 2,
- GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
+ G_TYPE_BOOLEAN, 4,
+ GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (class),
- _gtk_marshal_BOOLEAN__ENUM_INTv);
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
/**
* GtkFlowBox::select-all:
* @box: the #GtkFlowBox on which the signal is emitted
gint count);
static gboolean gtk_icon_view_real_move_cursor (GtkIconView *icon_view,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
static void gtk_icon_view_move_cursor_up_down (GtkIconView *icon_view,
gint count);
static void gtk_icon_view_move_cursor_page_up_down (GtkIconView *icon_view,
* @iconview: the object which received the signal
* @step: the granularity of the move, as a #GtkMovementStep
* @count: the number of @step units to move
+ * @extend: whether to extend the selection
+ * @modify: whether to modify the selection
*
* The ::move-cursor signal is a
* [keybinding signal][GtkBindingSignal]
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkIconViewClass, move_cursor),
NULL, NULL,
- _gtk_marshal_BOOLEAN__ENUM_INT,
- G_TYPE_BOOLEAN, 2,
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
+ G_TYPE_BOOLEAN, 4,
GTK_TYPE_MOVEMENT_STEP,
- G_TYPE_INT);
+ G_TYPE_INT,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (icon_view_signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (klass),
- _gtk_marshal_BOOLEAN__ENUM_INTv);
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
/* Key bindings */
gtk_widget_class_add_binding_signal (widget_class,
icon_view->priv->mouse_x = x;
icon_view->priv->mouse_y = y;
- device = gtk_get_current_event_device (); /* FIXME: controller device */
+ device = gtk_event_controller_get_current_event_device (controller);
gtk_icon_view_maybe_begin_drag (icon_view, x, y, device);
if (icon_view->priv->doing_rubberband)
gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask,
I_("move-cursor"),
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_SHIFT_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, FALSE);
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
return;
gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, TRUE);
gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, TRUE);
}
static gboolean
gtk_icon_view_real_move_cursor (GtkIconView *icon_view,
GtkMovementStep step,
- gint count)
+ gint count,
+ gboolean extend,
+ gboolean modify)
{
- GdkModifierType state;
-
g_return_val_if_fail (GTK_ICON_VIEW (icon_view), FALSE);
g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS ||
step == GTK_MOVEMENT_VISUAL_POSITIONS ||
gtk_cell_area_stop_editing (icon_view->priv->cell_area, FALSE);
gtk_widget_grab_focus (GTK_WIDGET (icon_view));
- if (gtk_get_current_event_state (&state))
- {
- GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
- GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
-
- if ((state & modify_mod_mask) == modify_mod_mask)
- icon_view->priv->modify_selection_pressed = TRUE;
- if ((state & extend_mod_mask) == extend_mod_mask)
- icon_view->priv->extend_selection_pressed = TRUE;
- }
- /* else we assume not pressed */
+ icon_view->priv->extend_selection_pressed = extend;
+ icon_view->priv->modify_selection_pressed = modify;
switch (step)
{
void (* toggle_cursor_item) (GtkIconView *icon_view);
gboolean (* move_cursor) (GtkIconView *icon_view,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
gboolean (* activate_cursor_item) (GtkIconView *icon_view);
};
void (*toggle_cursor_row) (GtkListBox *box);
void (*move_cursor) (GtkListBox *box,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
void (*selected_rows_changed) (GtkListBox *box);
void (*select_all) (GtkListBox *box);
void (*unselect_all) (GtkListBox *box);
static void gtk_list_box_toggle_cursor_row (GtkListBox *box);
static void gtk_list_box_move_cursor (GtkListBox *box,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
static void gtk_list_box_finalize (GObject *obj);
static void gtk_list_box_parent_cb (GObject *object,
GParamSpec *pspec,
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkListBoxClass, move_cursor),
NULL, NULL,
- _gtk_marshal_VOID__ENUM_INT,
- G_TYPE_NONE, 2,
- GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
+ _gtk_marshal_VOID__ENUM_INT_BOOLEAN_BOOLEAN,
+ G_TYPE_NONE, 4,
+ GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (klass),
- _gtk_marshal_VOID__ENUM_INTv);
+ _gtk_marshal_VOID__ENUM_INT_BOOLEAN_BOOLEANv);
widget_class->activate_signal = signals[ACTIVATE_CURSOR_ROW];
GtkMovementStep step,
gint count)
{
- GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
- GdkModifierType modify_mod_mask = GDK_CONTROL_MASK;
-
gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, FALSE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | extend_mod_mask,
+ keyval, modmask | GDK_SHIFT_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, FALSE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | modify_mod_mask,
+ keyval, modmask | GDK_CONTROL_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, TRUE);
gtk_widget_class_add_binding_signal (widget_class,
- keyval, modmask | extend_mod_mask | modify_mod_mask,
- "move-cursor",
- "(ii)", step, count);
+ keyval, modmask | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+ "move-cursor",
+ "(iibb)", step, count, TRUE, TRUE);
}
static void
}
}
-static void
-get_current_selection_modifiers (GtkWidget *widget,
- gboolean *modify,
- gboolean *extend)
-{
- GdkModifierType state = 0;
- GdkModifierType mask;
-
- *modify = FALSE;
- *extend = FALSE;
-
- if (gtk_get_current_event_state (&state))
- {
- mask = GDK_CONTROL_MASK;
- if ((state & mask) == mask)
- *modify = TRUE;
- mask = GDK_SHIFT_MASK;
- if ((state & mask) == mask)
- *extend = TRUE;
- }
-}
-
static void
gtk_list_box_click_unpaired_release (GtkGestureClick *gesture,
gdouble x,
GdkEventSequence *sequence;
GdkInputSource source;
GdkEvent *event;
- gboolean modify;
+ GdkModifierType state;
gboolean extend;
+ gboolean modify;
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
/* With touch, we default to modifying the selection.
* You can still clear the selection and start over
* by holding Ctrl.
*/
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
+ state = gdk_event_get_modifier_state (event);
+ extend = (state & GDK_SHIFT_MASK) != 0;
+ modify = (state & GDK_CONTROL_MASK) != 0;
source = gdk_device_get_source (gdk_event_get_source_device (event));
if (source == GDK_SOURCE_TOUCHSCREEN)
static void
gtk_list_box_move_cursor (GtkListBox *box,
GtkMovementStep step,
- gint count)
+ gint count,
+ gboolean extend,
+ gboolean modify)
{
- gboolean modify;
- gboolean extend;
GtkListBoxRow *row;
gint page_size;
GSequenceIter *iter;
return;
}
- get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
-
gtk_list_box_update_cursor (box, row, TRUE);
if (!modify)
gtk_list_box_update_selection (box, row, FALSE, extend);
gtk_list_box_row_set_focus (GtkListBoxRow *row)
{
GtkListBox *box = gtk_list_box_row_get_box (row);
- gboolean modify;
- gboolean extend;
if (!box)
return;
- get_current_selection_modifiers (GTK_WIDGET (row), &modify, &extend);
-
- if (modify)
- gtk_list_box_update_cursor (box, row, TRUE);
- else
- gtk_list_box_update_selection (box, row, FALSE, FALSE);
+ gtk_list_box_update_selection (box, row, FALSE, FALSE);
}
static gboolean
BOOLEAN:ENUM,BOXED,BOXED,BOXED
BOOLEAN:ENUM,DOUBLE
BOOLEAN:ENUM,INT
+BOOLEAN:ENUM,INT,BOOLEAN,BOOLEAN
BOOLEAN:FLAGS
BOOLEAN:OBJECT
BOOLEAN:OBJECT,UINT,FLAGS
VOID:ENUM,FLOAT,BOOLEAN
VOID:ENUM,INT
VOID:ENUM,INT,BOOLEAN
+VOID:ENUM,INT,BOOLEAN,BOOLEAN
VOID:ENUM,INT,INT
VOID:ENUM,OBJECT
VOID:ENUM,STRING
/* Key Binding signals */
gboolean (* move_cursor) (GtkTreeView *tree_view,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
gboolean (* select_all) (GtkTreeView *tree_view);
gboolean (* unselect_all) (GtkTreeView *tree_view);
gboolean (* select_cursor_row) (GtkTreeView *tree_view,
/* tree_model signals */
static gboolean gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
GtkMovementStep step,
- gint count);
+ gint count,
+ gboolean extend,
+ gboolean modify);
static gboolean gtk_tree_view_real_select_all (GtkTreeView *tree_view);
static gboolean gtk_tree_view_real_unselect_all (GtkTreeView *tree_view);
static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
/* interactive search */
static void gtk_tree_view_ensure_interactive_directory (GtkTreeView *tree_view);
static void gtk_tree_view_search_popover_hide (GtkWidget *search_popover,
- GtkTreeView *tree_view,
- GdkDevice *device);
+ GtkTreeView *tree_view);
static void gtk_tree_view_search_preedit_changed (GtkText *text,
const char *preedit,
GtkTreeView *tree_view);
static void gtk_tree_view_stop_editing (GtkTreeView *tree_view,
gboolean cancel_editing);
static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
- GdkDevice *device,
gboolean keybinding);
static gboolean gtk_tree_view_start_interactive_search (GtkTreeView *tree_view);
static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView *tree_view,
/**
* GtkTreeView::move-cursor:
* @tree_view: the object on which the signal is emitted.
- * @step: the granularity of the move, as a
- * #GtkMovementStep. %GTK_MOVEMENT_LOGICAL_POSITIONS,
- * %GTK_MOVEMENT_VISUAL_POSITIONS, %GTK_MOVEMENT_DISPLAY_LINES,
- * %GTK_MOVEMENT_PAGES and %GTK_MOVEMENT_BUFFER_ENDS are
- * supported. %GTK_MOVEMENT_LOGICAL_POSITIONS and
- * %GTK_MOVEMENT_VISUAL_POSITIONS are treated identically.
- * @direction: the direction to move: +1 to move forwards;
- * -1 to move backwards. The resulting movement is
- * undefined for all other values.
+ * @step: the granularity of the move, as a #GtkMovementStep.
+ * %GTK_MOVEMENT_LOGICAL_POSITIONS, %GTK_MOVEMENT_VISUAL_POSITIONS,
+ * %GTK_MOVEMENT_DISPLAY_LINES, %GTK_MOVEMENT_PAGES and
+ * %GTK_MOVEMENT_BUFFER_ENDS are supported.
+ * %GTK_MOVEMENT_LOGICAL_POSITIONS and %GTK_MOVEMENT_VISUAL_POSITIONS
+ * are treated identically.
+ * @direction: the direction to move: +1 to move forwards; -1 to move
+ * backwards. The resulting movement is undefined for all other values.
+ * @extend: whether to extend the selection
+ * @modify: whether to modify the selection
*
* The #GtkTreeView::move-cursor signal is a [keybinding
* signal][GtkBindingSignal] which gets emitted when the user
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkTreeViewClass, move_cursor),
NULL, NULL,
- _gtk_marshal_BOOLEAN__ENUM_INT,
- G_TYPE_BOOLEAN, 2,
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEAN,
+ G_TYPE_BOOLEAN, 4,
GTK_TYPE_MOVEMENT_STEP,
- G_TYPE_INT);
+ G_TYPE_INT,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
g_signal_set_va_marshaller (tree_view_signals[MOVE_CURSOR],
G_TYPE_FROM_CLASS (o_class),
- _gtk_marshal_BOOLEAN__ENUM_INTv);
+ _gtk_marshal_BOOLEAN__ENUM_INT_BOOLEAN_BOOLEANv);
tree_view_signals[SELECT_ALL] =
g_signal_new (I_("select-all"),
gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Page_Down, 0, TRUE,
GTK_MOVEMENT_PAGES, 1);
+ gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Right, 0, FALSE,
+ GTK_MOVEMENT_VISUAL_POSITIONS, 1);
+ gtk_tree_view_add_move_binding (widget_class, GDK_KEY_Left, 0, FALSE,
+ GTK_MOVEMENT_VISUAL_POSITIONS, -1);
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_Right, 0,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_Left, 0,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_KP_Right, 0,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_KP_Left, 0,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_Right, GDK_CONTROL_MASK,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_Left, GDK_CONTROL_MASK,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_KP_Right, GDK_CONTROL_MASK,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, 1);
-
- gtk_widget_class_add_binding_signal (widget_class,
- GDK_KEY_KP_Left, GDK_CONTROL_MASK,
- "move-cursor",
- "(ii)", GTK_MOVEMENT_VISUAL_POSITIONS, -1);
+ gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Right, 0, FALSE,
+ GTK_MOVEMENT_VISUAL_POSITIONS, 1);
+ gtk_tree_view_add_move_binding (widget_class, GDK_KEY_KP_Left, 0, FALSE,
+ GTK_MOVEMENT_VISUAL_POSITIONS, -1);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
gtk_widget_class_add_binding_signal (widget_class, GDK_KEY_KP_Space, GDK_CONTROL_MASK, "toggle-cursor-row", NULL);
}
static void
-get_current_selection_modifiers (GtkWidget *widget,
- gboolean *modify,
- gboolean *extend)
+get_current_selection_modifiers (GtkEventController *controller,
+ gboolean *modify,
+ gboolean *extend)
{
- GdkModifierType state = 0;
- GdkModifierType mask;
-
- *modify = FALSE;
- *extend = FALSE;
+ GdkModifierType state;
- if (gtk_get_current_event_state (&state))
- {
- mask = GDK_CONTROL_MASK;
- if ((state & mask) == mask)
- *modify = TRUE;
- mask = GDK_SHIFT_MASK;
- if ((state & mask) == mask)
- *extend = TRUE;
- }
+ state = gtk_event_controller_get_current_event_state (controller);
+ *modify = (state & GDK_CONTROL_MASK) != 0;
+ *extend = (state & GDK_SHIFT_MASK) != 0;
}
static void
gtk_tree_view_click_gesture_pressed (GtkGestureClick *gesture,
- gint n_press,
- gdouble x,
- gdouble y,
- GtkTreeView *tree_view)
+ int n_press,
+ double x,
+ double y,
+ GtkTreeView *tree_view)
{
GtkWidget *widget = GTK_WIDGET (tree_view);
GdkRectangle background_area, cell_area;
GtkCellRenderer *focus_cell;
gboolean modify, extend;
- get_current_selection_modifiers (widget, &modify, &extend);
+ get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
tree_view->modify_selection_pressed = modify;
tree_view->extend_selection_pressed = extend;
tree_view->rubber_band_y += tree_view->dy;
tree_view->rubber_band_status = RUBBER_BAND_MAYBE_START;
- get_current_selection_modifiers (GTK_WIDGET (tree_view), &modify, &extend);
+ get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
tree_view->rubber_band_modify = modify;
tree_view->rubber_band_extend = extend;
}
tree_view->button_pressed_node != tree_view->prelight_node)
return;
- get_current_selection_modifiers (GTK_WIDGET (tree_view), &modify, &extend);
+ get_current_selection_modifiers (GTK_EVENT_CONTROLLER (gesture), &modify, &extend);
if (tree_view->arrow_prelit)
{
gtk_event_controller_key_forward (key, tree_view->search_entry);
if (tree_view->imcontext_changed)
- {
- GdkDevice *device;
-
- device = gtk_get_current_event_device ();
- return gtk_tree_view_real_start_interactive_search (tree_view, device, FALSE);
- }
+ return gtk_tree_view_real_start_interactive_search (tree_view, FALSE);
}
}
if (tree_view->search_popover &&
!gtk_event_controller_focus_contains_focus (GTK_EVENT_CONTROLLER_FOCUS (focus)))
- gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view,
- gtk_get_current_event_device ());
+ gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
}
/* Incremental Reflow
static gboolean
gtk_tree_view_real_move_cursor (GtkTreeView *tree_view,
GtkMovementStep step,
- gint count)
+ gint count,
+ gboolean extend,
+ gboolean modify)
{
- GdkModifierType state;
-
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
g_return_val_if_fail (step == GTK_MOVEMENT_LOGICAL_POSITIONS ||
step == GTK_MOVEMENT_VISUAL_POSITIONS ||
tree_view->draw_keyfocus = TRUE;
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
- if (gtk_get_current_event_state (&state))
- {
- GdkModifierType extend_mod_mask;
- GdkModifierType modify_mod_mask;
-
- extend_mod_mask = GDK_SHIFT_MASK;
- modify_mod_mask = GDK_CONTROL_MASK;
-
- if ((state & modify_mod_mask) == modify_mod_mask)
- tree_view->modify_selection_pressed = TRUE;
- if ((state & extend_mod_mask) == extend_mod_mask)
- tree_view->extend_selection_pressed = TRUE;
- }
- /* else we assume not pressed */
+ tree_view->modify_selection_pressed = modify;
+ tree_view->extend_selection_pressed = extend;
switch (step)
{
GtkMovementStep step,
gint count)
{
-
gtk_widget_class_add_binding_signal (widget_class,
keyval, modmask,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, FALSE);
if (add_shifted_binding)
gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_SHIFT_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, TRUE, FALSE);
if ((modmask & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
return;
- gtk_widget_class_add_binding_signal (widget_class, keyval,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- "move-cursor",
- "(ii)", step, count);
-
gtk_widget_class_add_binding_signal (widget_class,
keyval, GDK_CONTROL_MASK,
"move-cursor",
- "(ii)", step, count);
+ "(iibb)", step, count, FALSE, TRUE);
+
+ if (add_shifted_binding)
+ gtk_widget_class_add_binding_signal (widget_class, keyval,
+ GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+ "move-cursor",
+ "(iibb)", step, count, TRUE, TRUE);
}
static gint
gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
{
GtkTreePath *cursor_path = NULL;
- GdkModifierType state;
if (!gtk_widget_has_focus (GTK_WIDGET (tree_view)))
goto out;
gtk_tree_path_up (cursor_path);
- if (gtk_get_current_event_state (&state))
- {
- GdkModifierType modify_mod_mask;
-
- modify_mod_mask = GDK_CONTROL_MASK;
-
- if ((state & modify_mod_mask) == modify_mod_mask)
- tree_view->modify_selection_pressed = TRUE;
- }
-
gtk_tree_view_real_set_cursor (tree_view, cursor_path, CLEAR_AND_SELECT | CLAMP_NODE);
gtk_tree_path_free (cursor_path);
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
- tree_view->modify_selection_pressed = FALSE;
-
return TRUE;
}
static gboolean
gtk_tree_view_search_entry_flush_timeout (GtkTreeView *tree_view)
{
- gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, NULL);
+ gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
tree_view->typeselect_flush_timeout = 0;
return FALSE;
*/
static gboolean
gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view,
- GdkDevice *device,
gboolean keybinding)
{
/* We only start interactive search if we have focus or the columns
static gboolean
gtk_tree_view_start_interactive_search (GtkTreeView *tree_view)
{
- return gtk_tree_view_real_start_interactive_search (tree_view,
- gtk_get_current_event_device (),
- TRUE);
+ return gtk_tree_view_real_start_interactive_search (tree_view, TRUE);
}
/* Callbacks */
static void
gtk_tree_view_search_popover_hide (GtkWidget *search_popover,
- GtkTreeView *tree_view,
- GdkDevice *device)
+ GtkTreeView *tree_view)
{
if (tree_view->disable_popdown)
return;
{
GtkTreePath *path;
- gtk_tree_view_search_popover_hide (tree_view->search_popover,
- tree_view,
- gtk_get_current_event_device ());
+ gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
/* If we have a row selected and it's the cursor row, we activate
* the row XXX */
double y,
GtkTreeView *tree_view)
{
- GdkDevice *keyb_device;
- GdkEventSequence *sequence;
- GdkEvent *event;
-
- sequence = gtk_gesture_get_last_updated_sequence (gesture);
- event = gtk_gesture_get_last_event (gesture, sequence);
- keyb_device = gdk_device_get_associated_device (gdk_event_get_device (event));
- gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view, keyb_device);
+ gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
}
static gboolean
if (!tree_view->search_custom_entry_set
&& gtk_tree_view_search_key_cancels_search (keyval))
{
- gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view,
- gtk_get_current_event_device ());
+ gtk_tree_view_search_popover_hide (tree_view->search_popover, tree_view);
return TRUE;
}